#!/usr/bin/python
# Copyright (c) 2021 Contributors to the Eclipse Foundation
# 
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
# 
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
# 
# SPDX-License-Identifier: EPL-2.0
#

import os, sys, time, json, getopt, subprocess, requests

# path = os.path.dirname(os.path.realpath(__file__))
# execfile(path + '/restapiPythonLib.py')


def main(argv):
   address = ''
   try:
      opts, args = getopt.getopt(argv,"ha:",["addr="])
   except getopt.GetoptError:
      print 'resolveaddr.py -a <address>'
      sys.exit(2)
   for opt, arg in opts:
      if opt == '-h':
         print 'resolveaddr.py -a <address>'
         sys.exit()
      elif opt in ("-a", "--addr"):
         address = arg

   os.system("grep " + address + " /etc/hosts | cut -d' ' -f1")

if __name__ == "__main__":
   main(sys.argv[1:])

